class Person {
  constructor(name, age) {
    this.name = name
    this.age = age
    this._address = '杭州市'
  }

  eating() {
    console.log(this.name + " eating")
  }

  sleeping() {
    console.log(this.name + " sleeping")
  }

  // 类的访问器方法
  get address() {
    console.log("拦截访问操作")
    return this._address
  }
  set address(newAddr) {
    console.log("拦截设置操作")
    this._address = newAddr
  }

  // 静态方法
  static randomPerson() {
    return new Person()
  }
}

var p = new Person("yz", 20)
console.log(address)
